<?xml version="1.0" encoding="UTF-8"?>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:p="http://primefaces.org/ui"
	template="/WEB-INF/templates/default.xhtml">
	<ui:define name="content">
			<h:form id="userForm">
				<p:watermark id="emailWatermark" for="email" value="Email" />
				<p:inputText id="email" value="#{usersAdministrationBackingBean.newUser.email}" />
				
				<p:watermark id="passwordWatermark" for="password" value="Password" />
				<p:inputText id="password" value="#{usersAdministrationBackingBean.newUser.password}" />
				
				<h:outputLabel id="roleLabel" for="role" value="Role"/>
				<p:selectOneMenu id="role" value="#{usersAdministrationBackingBean.newUser.role}" >
					<f:selectItems value="#{usersAdministrationBackingBean.allUsersRole}"/>
				</p:selectOneMenu>
				
				<p:commandButton action="#{usersAdministrationBackingBean.addNewUser()}" value="Add user" update=":userForm" />
				
				<p:dataTable id="allUsers" var="user" value="#{usersAdministrationBackingBean.allUsers}" >  
  
			        <p:column headerText="Email" style="width:100px">  
			            <h:outputText value="#{user.email}" />  
			        </p:column>
			  
			        <p:column headerText="Role" style="width:100px">  
			            <h:outputText value="#{user.role}" />  
			        </p:column>  
			        
			        <p:column style="width:40px">  
						<p:commandButton id="deleteButton" update=":userForm" value="Delete" action="#{usersAdministrationBackingBean.removeUser(user.id)}"/>   
			        </p:column>
			        
			        <p:column style="width:40px">  
						<p:commandButton id="editButton" value="Edit" action="#{usersAdministrationBackingBean.selectUser(user)}" oncomplete="editUserDialogWidget.show()"/>   
			        </p:column>
			  
			    </p:dataTable>
			    
			</h:form>
	</ui:define>
</ui:composition>
